/*
 * @(#)NoticeDAOImpl.java $version 2012-8-10
 * 
 * Copyright 2012 NADOSTAR Gruop. All rights Reserved.
 * NADOSTAR PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nadostar.iims.etc.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.nadostar.extensions.SimpleSqlMapDaoSupport;
import com.nadostar.extensions.util.DataMap;
import com.nadostar.iims.etc.dao.NoticeDAO;
import com.nadostar.iims.model.Notice;

/**
 * The Class NoticeDAOImpl.
 * 
 * @author Lixing
 *
 */
@Repository("NoticeDAO")
public class NoticeDAOImpl extends SimpleSqlMapDaoSupport implements NoticeDAO {
	private static final String PREFIX = "com.nadostar.iims.etc.notice.";
	
	@SuppressWarnings("unchecked")
	public List<DataMap> selectNoticeList(String ntcTypeCd, String delYn, int offset, int count) throws DataAccessException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ntcTypeCd", ntcTypeCd);
		params.put("delYn", delYn);
		params.put("offset", offset);
		params.put("count", count);
		
		return getSqlMapClientTemplate().queryForList(PREFIX + "selectNoticeList", params);
	}

	public int selectNoticeListCount(String ntcTypeCd, String delYn) throws DataAccessException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ntcTypeCd", ntcTypeCd);
		params.put("delYn", delYn);
		
		return (Integer) getSqlMapClientTemplate().queryForObject(PREFIX + "selectNoticeListCount", params);
	}

	public Notice selectNoticeDetail(int ntcSeq) throws DataAccessException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ntcSeq", ntcSeq);
		
		return (Notice) getSqlMapClientTemplate().queryForObject(PREFIX + "selectNoticeDetail", params);
	}

	public int insertNotice(Notice notice) throws DataAccessException {
		return getSqlMapClientTemplate().update(PREFIX + "insertNotice", notice);
	}

	public int updateNotice(Notice notice) throws DataAccessException {
		return getSqlMapClientTemplate().update(PREFIX + "updateNotice", notice);
	}

	public int deleteNotice(int ntcSeq, String delYn) throws DataAccessException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ntcSeq", ntcSeq);
		params.put("delYn", delYn);
		
		return getSqlMapClientTemplate().update(PREFIX + "deleteNotice", params);
	}

}
